<template>
  <div class="wh">
    <commonshownumzzn
      :type="'mianji'"
      :num="numval"
      :typestr.sync="numstr"
      :componentDetail="componentDetail"
    />
  </div>
</template>
<script>
import dayjs from "dayjs";

import titlemixins from "@/mixins/bigScreen/titlemixins";
import commonmixins from "@/mixins/bigScreen/commonmixins";

import axios from "@/utils/requestdp";

export default {
  name: "cainuantianshuzznnn",
  mixins: [titlemixins, commonmixins],
  components: {},
  data() {
    return {
      numval: "0",
      numstr: "采暖天数/天",
    };
  },
  computed: {
    linglongstyleses() {
      return {
        height: "100%",
      };
    },
    timestyles() {
      return {
        fontSize: this.getscalepxc(35),
      };
    },
    ymdstyles() {
      return {
        fontSize: this.getscalepxc(15),
        color: "#50C9FF",
      };
    },
  },
  watch: {
    // "$store.state.daping.bigScreen": {
    //   handler(n, o) {
    //     this.loadData(n)
    //   }
    // },
  },
  mounted() {
    axios.get("/heatperiod/heatingDays").then((res) => {
      if (res.code == 200) {
        this.loadData(res.data);
      }
    });
  },
  methods: {
    loadData(date) {
      // let gongnuanDayStart = new Date().getFullYear() + res.filter(v => v.attrName === 'start_date')[0].attrValue.substr(4);
      // let gongnuanDayEnd = new Date().getFullYear() + '-' + res.filter(v => v.attrName === 'end_date')[0].attrValue;
      // let today = dayjs().format('YYYY-MM-DD');
      // if (new Date(today).getTime() > new Date(gongnuanDayEnd).getTime() && new Date(today).getTime() < new Date(gongnuanDayStart).getTime()) {
      //   this.numstr = "采暖倒计时/天";
      //   this.numval = dayjs(gongnuanDayStart).diff(today, 'day');
      // } else if (new Date(today).getTime() == new Date(gongnuanDayStart).getTime()) {
      //   this.numstr = "采暖天数/天";
      //   this.numval = 1;
      // } else {
      //   this.numstr = "采暖天数/天";
      //   this.numval = dayjs(today).diff(gongnuanDayStart, 'day') + 1;
      // }
      let start_data = date["start_time"];
      let end_data = date["end_time"];

      if (dayjs().diff(dayjs(end_data), 'day') > 0) {
        let days = dayjs().diff(dayjs(start_data).add(1,'year'), "day") + 1;
        this.numval = -days;
        this.numstr = "采暖倒计时/天";
        
      }else{
        let days = dayjs().diff(dayjs(start_data), "day") + 1;
        this.numval = days;
        this.numstr = "采暖第/天";
      }

    },
  },
};
</script>
<style lang='scss' scoped>
.titletime {
  height: 100%;
}
.timediv {
  font-family: DS-Digital;
  /*font-size:70px;*/
  font-weight: bold;
  color: rgba(255, 255, 255, 1);
}
</style>